﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EF_Model
{
    public class CustomerRepository
    {
        private DatabaseContext _context;

        public CustomerRepository(DatabaseContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context was null");
            _context = context;
        }
        
        // Read operations

        public Customer GetById(string id)
        {
            var first = _context.Customers.FirstOrDefault(c => c.CustomerID == id);
            return first;
        }

        //In-memory CUD operations

        public void AddCustomer(Customer customer)
        {
            _context.Customers.AddObject(customer);
        }

        //public void AddToCustomer(Customer customer)
        //{
        //    _context.AddToCustomers(customer);
        //}

        public void DeleteCustomer(Customer customer)
        {
            _context.Customers.DeleteObject(customer);
        }

        //public void DeleteFromCustomers(Customer customer)
        //{
        //    _context.DeleteObject(customer);
        //}

        // Parsistance operation

        
    }
}
